package cn.foolishbird.hamal.frame.exception.base;

import cn.foolishbird.hamal.frame.bsassert.info.RstInfo;
import lombok.Data;

/**
 * @author Eric
 * @version 1.0
 * @date 2019-12-13
 */
@Data
public abstract class BaseException extends RuntimeException implements RstInfo {

    private int code;

    private String content;

    private Object data;


    public BaseException(int code, String content, Object data) {
        this.code = code;
        this.content = content;
        this.data = data;
    }

    public BaseException(String message, int code, String content, Object data) {
        super(message);
        this.code = code;
        this.content = content;
        this.data = data;
    }

    public BaseException(String message, Throwable cause, int code, String content, Object data) {
        super(message, cause);
        this.code = code;
        this.content = content;
        this.data = data;
    }

    public BaseException(Throwable cause, int code, String content, Object data) {
        super(cause);
        this.code = code;
        this.content = content;
        this.data = data;
    }

    public BaseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, int code, String content, Object data) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.code = code;
        this.content = content;
        this.data = data;
    }

    @Override
    public int code() {
        return code;
    }

    @Override
    public String content() {
        return content;
    }

    @Override
    public Object data() {
        return this.data;
    }

    @Override
    public String errorMessage() {
        return this.getMessage();
    }
}
